﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using StuMngWx.Dals;
using StuMngWx.Entities;
using StuMngWx.Enums;

namespace StuMngWx
{
    public partial class FormAddStudent : Form
    {
        public FormAddStudent()
        {
            InitializeComponent();
        }

        private void FormAddStudent_Load(object sender, EventArgs e)
        {
            //cboSex.Items.Add(1);
            //cboSex.Items.Add(0);

            cboSex.Items.Add(Sex.Male);
            cboSex.Items.Add(Sex.Famale);
            cboSex.SelectedIndex = 0;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            //string sName=txtName.Text;
            //bool bSex=Convert.ToBoolean(cboSex.SelectedItem);
            //string sAddress=txtAddress.Text;
            //Dal4Student.InsertStudent(sName, bSex, sAddress);

            Student student = new Student();

            student.Name = txtName.Text;
            student.Address = txtAddress.Text;
            student.Sex_Field = cboSex.SelectedItem.ToString();

            Dal4Student.InsertStudent(student);
            MessageBox.Show(string.Format("插入学生【{0}】成功", student.Name));
        }
    }
}
